<template>
  <div>login</div>
</template>

<script>
import {login,getMenu} from "@/api/base/login"
import {getButtons,getMenus} from "@/utils/menuTree"

export default {
  methods:{
    async login(){
      try{
        const token = await login();
        const tree = await getMenu();
        // console.log(token)
        // console.log(tree)
        // 解析数据 并存入 store 中
        const mt = tree.result;
        const buttons = getButtons(mt);
        const menus = getMenus(mt);
        this.$store.commit('setButtons',buttons)
        this.$store.commit('setMenus',menus)
        //
        // console.log(this.$router)
        this.$router.$rebuild()
        console.log(this.$router.getRoutes())
      }catch(e){console.log(e)}
    }
  },
  created(){
    this.login()
  }
}
</script>